package fussbudget.gui.components.support;

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import org.joda.money.Money;
import org.joda.time.DateMidnight;

import com.lavantech.gui.comp.DateTimePicker;

import fussbudget.Address;
import fussbudget.PaymentEntity;

public class TablePanelRenderer extends DefaultTableCellRenderer {
	public TablePanelRenderer() {
		super();
	}

	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
		if (value instanceof String) {
			return new JLabel((String) value);
		} else if (value instanceof Address) {
			return new JLabel("address");
		} else if (value instanceof DateMidnight) {
			return new DateTimePicker(((DateMidnight) value).toDate(), "MM/dd/yyyy", true, false);
		} else if (value instanceof Money) {
			return new JLabel(((Money) value).toString());
		}
		return new JLabel("???");
	}
}
